﻿using DHQGHN.DAL.DAO.DHQG;
using DHQGHN.DAL.Models.DHQG;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DHQGHN.DAL.BO.DHQG
{
    public class ExportExcellBO : BaseBO
    {
        private ExportExcellDAO _sqlDAO;
        public ExportExcellBO()
        {
            _sqlDAO = new ExportExcellDAO(Common.ConnectionUtil.DHQGHN_CONNECTION_STRING, DEFAULT_MAPPER_TYPE);
        }

        public List<ExportExcell> GetDataKeHoachDHQG(int namKeHoachId, int donViId, int nhomDonViId, int status, string maCap1)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();
                return _sqlDAO.GetDataKeHoachDHQG(namKeHoachId, status, maCap1, mapDictionary);

            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetDataKeHoach(int namKeHoachId, int donViId, int nhomDonViId, int statusId, string maCap1)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();
                return _sqlDAO.GetDataKeHoachDonVi(namKeHoachId, donViId, nhomDonViId, statusId, maCap1, mapDictionary);
            }
            catch
            {
                throw;
            }
        }


        public List<ExportExcell> GetDataKeHoachThucHienDHQG(int namKeHoachId, string maCap1)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();
                return _sqlDAO.GetDataKeHoachThucHienDHQG(namKeHoachId, maCap1, mapDictionary);

            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetDataKeHoachThucHien(int namKeHoachId, int donViId, int nhomDonViId, string maCap1)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();
                return _sqlDAO.GetDataKeHoachThucHienDonVi(namKeHoachId, donViId, nhomDonViId, maCap1, mapDictionary);
            }
            catch
            {
                throw;
            }
        }


        public List<ExportExcell> GetListChiTieuDHQG(int namKH, int statusId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();

                return _sqlDAO.GetListChiTieuDHQG(namKH, statusId, mapDictionary);

            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetListChiTieuDonVi(int namKH, int statusId, int donViId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();
                return _sqlDAO.GetListChiTieuDonVi(namKH, statusId, donViId, mapDictionary);
            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetListKeHoachThucHienDHQG(int namKH, int statusId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();

                return _sqlDAO.GetListKeHoachThucHienDHQG(namKH, statusId, mapDictionary);
            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetListKeHoachThucHienDonVi(int namKH, int statusId, int donViId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();

                return _sqlDAO.GetListKeHoachThucHienDonVi(namKH, statusId, donViId, mapDictionary);

            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetListKeHoachThucHienDonVi2(int namKH, int statusId, int donViId, int mocKS)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();

                return _sqlDAO.GetListKeHoachThucHienDonVi2(namKH, statusId, donViId, mocKS, mapDictionary);

            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetListBanPhuTrach(int namKH, int statusId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();
                return _sqlDAO.GetListBanPhuTrach(namKH, statusId, mapDictionary);
            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetListChiTieuDHQG_TheoNhom(int namKH, int statusId, int donViId, int nhomDonViId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();
                return _sqlDAO.GetListChiTieuDHQG_TheoNhom(namKH, statusId, donViId, nhomDonViId, mapDictionary);

            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetListChiTieuDonVi_TheoNhom(int namKH, int statusId, int donViId, int nhomDonViId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();
                return _sqlDAO.GetListChiTieuDonVi_TheoNhom(namKH, statusId, donViId, nhomDonViId, mapDictionary);
            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetListKeHoachThucHienDHQG_TheoNhom(int namKH, int statusId, int donViId, int nhomDonViId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();
                return _sqlDAO.GetListKeHoachThucHienDHQG_TheoNhom(namKH, statusId, donViId, nhomDonViId, mapDictionary);
            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetListKeHoachThucHienDonVi_TheoNhom(int namKH, int statusId, int donViId, int nhomDonViId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();
                return _sqlDAO.GetListKeHoachThucHienDonVi_TheoNhom(namKH, statusId, donViId, nhomDonViId, mapDictionary);
            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetListKeHoachThucHienDonVi_TheoNhom2(int namKH, int statusId, int donViId,int mocKS, int nhomDonViId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();
                return _sqlDAO.GetListKeHoachThucHienDonVi_TheoNhom2(namKH, statusId, donViId, mocKS, nhomDonViId, mapDictionary);
            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetListChiTieuRiengDonVi_KeHoachThucHien(int namKhId, int donViID)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();
                return _sqlDAO.GetListChiTieuRiengDonVi_KeHoachThucHien(namKhId, donViID, mapDictionary);
            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetListChiTieuRiengDonVi_KeHoach(int namKhId, int donViId, int statusId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();

                return _sqlDAO.GetListChiTieuRiengDonVi_KeHoach(namKhId, donViId, statusId, mapDictionary);
            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetListBanPhuTrach_TheoDonVi(int namKH, int statusId, int donViId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();

                return _sqlDAO.GetListBanPhuTrach_TheoDonVi(namKH, statusId, donViId, mapDictionary);
            }
            catch
            {
                throw;
            }
        }

        public int GetSoLuongDonViSuDungChiTieu(int namKhId, int chiTieuId)
        {
            try
            {
                return _sqlDAO.GetSoLuongDonViSuDungChiTieu(namKhId, chiTieuId);
            }
            catch
            {
                throw;
            }
        }

        public bool DaDieuChinh(int namKhId, int statusId)
        {
            try
            {
                return _sqlDAO.DaDieuChinh(namKhId, statusId);
            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetChiTieuDinhHuong(int namKhId, int statusId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();
                return _sqlDAO.GetChiTieuDinhHuong(namKhId, statusId, mapDictionary);
            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetListChiTieuDonViTrongBangComment(int namKhId, int donViId, int statusId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();
                return _sqlDAO.GetListChiTieuDonViTrongBangComment(namKhId, donViId, statusId, mapDictionary);
            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetListChiTieuTrongBangComment(int namKhId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();

                return _sqlDAO.GetListChiTieuTrongBangComment(namKhId, mapDictionary);
            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetListChiTieuDinhHuongTrongBangComment(int namKhId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();

                return _sqlDAO.GetListChiTieuDinhHuongTrongBangComment(namKhId, mapDictionary);
            }
            catch
            {
                throw;
            }
        }

        public ExportExcell GetByChiTieuIdInCommentTable(int namKhId, int donViId, int statusId, int chiTieuId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();
                return _sqlDAO.GetByChiTieuIdInCommentTable(namKhId,donViId, statusId, chiTieuId, mapDictionary);

            }
            catch
            {
                throw;
            }
        }

        public ExportExcell GetByChiTieuIdInKeHoachTable(int namKhId, int donViId, int statusId, int chiTieuId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();

                return _sqlDAO.GetByChiTieuIdInKeHoachTable(namKhId, donViId, statusId, chiTieuId, mapDictionary);

            }
            catch
            {
                throw;
            }
        }

        public List<ExportExcell> GetListChiTieuCacDonViKhongDeXuat(int namKhId, int donViId, int statusId)
        {
            try
            {
                Dictionary<string, string> mapDictionary = GetMapDictionary();
                return _sqlDAO.GetListChiTieuCacDonViKhongDeXuat(namKhId, donViId, statusId, mapDictionary);
            }
            catch
            {
                throw;
            }
        }


        private Dictionary<string, string> GetMapDictionary()
        {
            Dictionary<string, string> mapDictionary = new Dictionary<string, string>()
            {
                 {"GIA_TRI", "GIA_TRI"},
                 {"CHI_TIEU_ID", "CHI_TIEU_ID"},
                 {"TEN_CHI_TIEU","TEN_CHI_TIEU"},                 
                 {"CAP","CAP"},
                 {"MA_CAP1","MA_CAP1"},
                 {"MA_CAP2","MA_CAP2"},
                 //,
                 //{"TEN_CHI_TIEU_CAP1","TEN_CHI_TIEU_CAP1"},
                 //{"TEN_CHI_TIEU_CAP2","TEN_CHI_TIEU_CAP2"},                             
                 {"DON_VI", "DON_VI" },
                 //{"MA_DON_VI","MA_DON_VI"},
                 //{"DON_VI","DON_VI"},
                 {"DON_VI_TINH","DON_VI_TINH"},
                 {"LA_CHI_TIEU_AO","LA_CHI_TIEU_AO"},
                 {"CHO_PHEP_TINH_TONG","CHO_PHEP_TINH_TONG"},
                 {"COMMENT", "COMMENT"}
            };
            return mapDictionary;
        }
    }
}
